package cn.onestoplog.currEx.common;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	public static Timestamp date2TimeStamp(Date dt){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
		String time = sdf.format(dt);   
		Timestamp res = Timestamp.valueOf(time); 
		return res;
	}
	public static Timestamp date2TimeStamp(){
		return
				date2TimeStamp(new Date());
	}
	
	public static Date str2Date(String dt_str) throws ParseException{
		SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm");  
		Date res = sdf.parse(dt_str);   
		return res;
	}
	public static void main(String[] args) {
		try {
			System.out.println(str2Date("9/3/2012 6:17am"));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
}
